package com.mypro._01base.test;

import com.mypro._01base.dbutil.DbUtil;
import com.mypro._01base.entity.Idcard;
import com.mypro._01base.entity.Person;
import com.mypro._01base.mapper.IdcardMapper;
import com.mypro._01base.mapper.PersonMapper;
import org.apache.log4j.Logger;
import org.junit.jupiter.api.Test;

import java.util.List;

/**
 * @author user_xdd
 * @Date 2022-05-14 15:19
 * @description 03 多对多 多对一 一对一
 * @return
 */
public class IdAndPerson {
    private static final Logger LOGGER = Logger.getLogger(IdAndPerson.class);

    @Test
    public void id() {
        PersonMapper personMapper = DbUtil.getSqlSession().getMapper(PersonMapper.class);
        IdcardMapper idcardMapper = DbUtil.getSqlSession().getMapper(IdcardMapper.class);
        //================person======================
        
        /*
        List<Person> people = personMapper.queryAll();
        for (Person person : people) {
             LOGGER.debug("    person:"+person);
        }
*/
        Person person1 = personMapper.queryByPrimaryKey(1);
         LOGGER.debug("    person1:"+person1);
        Idcard idcard1 = person1.getIdcard();
         LOGGER.debug("    idcard1:"+idcard1);
        //================测试id======================
        List<Idcard> idcards = idcardMapper.queryAll();
        for (Idcard idcard : idcards) {
             LOGGER.debug("    idcard:"+idcard);
            Person person = idcard.getPerson();
             LOGGER.debug("    person:"+person);
        }

    }
}
